package structure.adapter.adapter_demo1;

/**
 * @author yeyangtao
 * @date 2020/6/2 19:29
 */
public class MediaAdapter implements MediaPlayer {
    AdviceMediaPlayer adviceMediaPlayer;

    @Override
    public void play(String audioType, String fileName) {
        if ("vlc".equals(audioType)) {
            adviceMediaPlayer.playVlc(fileName);
        } else if ("mp4".equals(audioType)) {
            adviceMediaPlayer.playMp4(fileName);
        }
    }

    public MediaAdapter(String audioType) {
        if ("vlc".equals(audioType)) {
            adviceMediaPlayer = new VlcPlayer();
        } else if ("mp4".equals(audioType)) {
            adviceMediaPlayer = new Mp4Player();
        }
    }
}
